#include "sht.h"

ClosedCube_SHT31D _sht31;
SHT31D sht_res;
SHT31 sht31;

void shtInit(void)
{
    _sht31.begin(0x44);   
    if (_sht31.periodicStart(SHT3XD_REPEATABILITY_HIGH, SHT3XD_FREQUENCY_1HZ) != SHT3XD_NO_ERROR)
        Serial.println("[ERROR] Cannot start periodic mode");
}

void shtTask(void)
{
    // sht_res = _sht31.readTempAndHumidity(SHT3XD_REPEATABILITY_LOW, SHT3XD_MODE_CLOCK_STRETCH, 50);    
    sht_res = _sht31.periodicFetchData();
    sht31.temp = (uint16_t)(sht_res.t*100);
    sht31.humi = (uint16_t)(sht_res.rh*100);
}
